from django.http import JsonResponse


def resp_success(data=None, **kwargs):
    resp = {
        'code': 0,
    }
    if data is not None:
        resp['data'] = data
    return JsonResponse({
        **resp,
        **kwargs
    })


def resp_error(msg='', status=200, **kwargs):
    resp = {
        "code": 500,
        **kwargs
    }
    if msg != '':
        resp['msg'] = msg
    return JsonResponse(resp, status=status)
